Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for BananaPi BPi-R2 #1135

Closed
wants to merge 11 commits into from
Closed

Conversation

abbradar
Copy link

@abbradar abbradar commented Jul 2, 2018

This is a minimal amount of patches to build working images for Banana Pi BPi-R2. Remaining major issues now are:

  • Boot from EMMC is not supported, only SD (see explanation in 03c35cec00db8ab51544346def64ea82111f29ca);
  • Internal Wi-Fi is broken (see below);
  • HNAT/HW QoS are not supported (see 7762c07).

Developers from BananaPi provide half-complete drivers for Mediatek connectivity chip which apparently are hacked Android drivers. Because of this:

  • Drivers need to be compiled into the kernel along with cfg80211 which conflicts with drivers for PCIe cards;
  • Their drivers confuse our network stack by creating network devices by themselves (just look at the procedure for initialization); we will likely need a separate backend for wifi to handle that.

@abbradar abbradar force-pushed the bpi-upstream branch 2 times, most recently from fc07402 to ca4c162 Compare July 2, 2018 15:37
@mkresin mkresin added the target/mediatek pull request/issue for mediatek target label Jul 2, 2018
Backported from the vendor tree with additional patches to build with GCC 7.

Signed-off-by: Nikolay Amiantov <ab@fmap.me>
It's useful on BPi-R2.

Signed-off-by: Nikolay Amiantov <ab@fmap.me>
This is a minimal amount of patches to get the router functional:

* Hardcode kernel cmdline arguments in DTB for now (which means only SD image
  works, EMMC requires different partition settings);
* Fix device memory size;
* Fix LEDs settings;
* Enable PCIe support;
* Enable TRGMII on both GMACs which fixes LAN.

Non-functional features:
* Internal Wi-Fi (but you can use a PCIe card);
* HW NAT/HW QoS;

Untested features:
* HDMI;
* GPIO pins.

All the changes apart from hardcoding cmdline are picked from the vendor's 4.9
tree.  Vendor supplements needed bootargs via u-boot instead, which for some
reason doesn't work.

Signed-off-by: Nikolay Amiantov <ab@fmap.me>
As mentioned in kernel patches only SD image is supported for now, however most
needed code for EMMC images is added.

Signed-off-by: Nikolay Amiantov <ab@fmap.me>
General idea is copied from the vendor tree.

Signed-off-by: Nikolay Amiantov <ab@fmap.me>
Needed for MT6625L support on BananaPi BPi-R2.
Stand-alone WLAN drivers for Banana Pi BPi-R2.
Userspace part of WLAN drivers for BananaPi BPi-R2.

Additionally implement wireless config initialization and start/stop/reload
with quirks needed for the radio.
Certain wireless drivers (Mediatek) create interfaces by themselves and report
"not supported" error when trying to create one from userspace. Handle this
error code.
This is needed for some devices that handle non-zero values incorrectly, like
BananaPi BPi-R2 onboard wifi chip.
Use phy device name as a last resort for identifying radios when reported MAC
address is invalid.

This is needed for Banana Pi BPi-R2 onboard wifi chip.
@abbradar
Copy link
Author

I've managed to implement working internal Wi-Fi. Things are still very quirky but it appears to work with stock OpenWrt infrastructure (with some changes).

# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should be turned into a real image building code template and not a shell script from within the image code.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would one do that? Maybe there are examples in the code tree that I can use?

@@ -18,6 +18,15 @@ platform_do_upgrade() {
sync
umount /tmp/recovery
;;
bananapi,bpi-r2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change included inside the patch does not correlate with the patches subject/description

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure what do you mean - I add support for sysupgrade here, and it says so in the patch subject. Should I rename it somehow?

*/
memory {
- reg = <0 0x80000000 0 0x20000000>;
+ reg = <0 0x80000000 0 0x80000000>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch the dts file directly

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blogic Ping?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abbradar: mt7623n-bananapi-bpi-r2.dts is upstream DTS file, if there is something wrong in it, please send upstream patch for that

Copy link

@frank-w frank-w Nov 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blue {
label = "bpi-r2:pio:blue";
- gpios = <&pio 241 GPIO_ACTIVE_HIGH>;
+ gpios = <&pio 240 GPIO_ACTIVE_LOW>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch the dts file directly

};

+&pcie {
+ pinctrl-names = "default";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch the dts file directly

@@ -58,6 +58,13 @@ CONFIG_BOUNCE=y
CONFIG_CC_STACKPROTECTOR=y
# CONFIG_CC_STACKPROTECTOR_NONE is not set
CONFIG_CC_STACKPROTECTOR_REGULAR=y
CONFIG_CFG80211=m
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont use the kernel builtin cfg80211 layer

@blogic
Copy link
Contributor

blogic commented Aug 6, 2018

you are trying to add a driver with 1/4 million lines here cough :-)

@blogic
Copy link
Contributor

blogic commented Aug 6, 2018

@abbradar Hi, although i really appreciate your effort in improving the bananpiR2 support, I must admit that chances of these changes getting merged are near 0. we could merge the memory size cleanup and the console/commandline fix but the rest wont ever hit the master tree. the wifi driver alone is 1/4 million lines of code, requires the in-kernel cfg80211 layer, hostapd hacks. The quality of the rest of the patches is somewhat questionable as it was most likely copied 1:1 from the SDK.
sorry, if you want the minor fixes merged, open a dedicated PR for them.

@blogic blogic closed this Aug 6, 2018
Copy link
Author

@abbradar abbradar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blogic Many thanks for your review! I'll split and fix these patches, resubmitting some parts. I propose merging general improvements for the device, without internal WiFi support. Would this be okay?

*/
memory {
- reg = <0 0x80000000 0 0x20000000>;
+ reg = <0 0x80000000 0 0x80000000>;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean?

@abbradar
Copy link
Author

abbradar commented Jun 1, 2019

@frank-w I'll try to rebase this atop master, will see what I can do.

@abbradar
Copy link
Author

I've rebased and tested this; it works but for some reason jffs2 isn't mounted so there's no persistence. Unfortunately I had to RMA my CPU so I won't be able to look further for some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/mediatek pull request/issue for mediatek target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants